import axios from 'axios'
// import store from '../store'
import Vue from 'vue'

// export const baseUrl = 'http://101.132.181.9/';

const axiosInstance = axios.create({
    // baseURL: baseUrl
})

axiosInstance.interceptors.request.use(config => {
    return config
}, error => {
    return Promise.reject(error)
})

axiosInstance.interceptors.response.use(
    res => {
        console.log(res);
        // 没有权限 后端接口 code 
        // 服务器端的返回
        if (res.data.code === '401') {
            // store.dispatch('setShowLogin', true);
            Vue.prototype.notifyError('请登录');
        }else if(res.data.code==='500'){
            Vue.prototype.notifyError('服务器端错误')
        }
        return res
    }
)

export { axiosInstance }
